Skip to content

feat(rtsp): add ZTE NAT traversal mode - #701

Open
stackia wants to merge 3 commits into
mainfrom
codex/rtsp-zte-nat
Open

feat(rtsp): add ZTE NAT traversal mode#701
stackia wants to merge 3 commits into
mainfrom
codex/rtsp-zte-nat

Conversation

@stackia

@stackia stackia commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add rtsp-nat-mode = auto|stun|zte with CLI override. Auto uses STUN when rtsp-stun-server is configured and otherwise leaves NAT traversal disabled.
  • Implement the ZTE ZXV10STB NAT punch flow using the actual local and peer endpoints of the connected RTSP TCP socket.
  • Bind ZTE RTP/RTCP sockets to the selected local IPv4 address and keep TCP, SETUP, and UDP endpoint information aligned on multi-interface systems.
  • Add OpenWrt, iKuai, sample configuration, and Chinese/English documentation updates.
  • Add byte-level E2E coverage for the ZTE packet, interface selection, redirects, IPv6 fallback, STUN isolation, mode validation, and reload behavior.

Why

Issue #700 shows a failure mode consistent with symmetric NAT, where a STUN-derived mapping may not remain valid for the RTSP media server. This adds the ZTE-specific traversal mode as an independent implementation based on observable wire behavior.

Impact

The available modes are Auto, STUN, and ZTE. Auto is the default and preserves existing STUN behavior when a server is configured. ZTE mode is IPv4-only and falls back to ordinary RTSP negotiation for IPv6 upstreams.

Refs #700.

Validation

  • Release CMake build
  • pnpm run lint
  • pnpm run docs:build
  • ZTE/Auto E2E suite: 10 passed
  • STUN E2E suite: 5 passed
  • Configuration E2E suite: 45 passed
  • Full E2E suite: 565 passed, 8 skipped
  • OpenWrt/iKuai JSON, shell, and gettext checks

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Documentation preview

The documentation preview has been deployed for this pull request.

@stackia
stackia marked this pull request as ready for review August 3, 2026 10:57
@stackia
stackia requested a review from Copilot August 3, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an explicit RTSP NAT traversal mode selection (none|stun|zte) and implements ZTE ZXV10STB NAT punching by deriving the actual local/peer endpoints from the established RTSP TCP control socket, keeping UDP socket binding aligned on multi-interface systems. It also updates OpenWrt/iKuai integration, configuration samples, and adds E2E coverage for the new mode and compatibility behavior.

Changes:

  • Add rtsp-nat-mode (config + CLI) with legacy STUN inference via config_get_effective_rtsp_nat_mode().
  • Implement ZTE NAT punch flow and control-endpoint capture; bind UDP sockets to the RTSP TCP-selected local IPv4 when in ZTE mode.
  • Add OpenWrt/iKuai wiring, docs updates, and new E2E tests + mock server behavior for ZTE.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/rtsp.h Extend RTSP session state with captured control socket endpoints and ZTE mode flags.
src/rtsp.c Implement endpoint capture, ZTE header + probe behavior, and ZTE-aligned UDP binding.
src/configuration.h Introduce rtsp_nat_mode_t and expose effective NAT-mode resolver API.
src/configuration.c Parse/validate rtsp-nat-mode, add CLI flag, and implement legacy inference logic.
rtp2httpd.conf Document new NAT mode option in sample config.
openwrt-support/rtp2httpd/files/rtp2httpd.init Pass --rtsp-nat-mode from UCI config to daemon.
openwrt-support/rtp2httpd/files/rtp2httpd.conf Add UCI option example for rtsp_nat_mode.
openwrt-support/luci-app-rtp2httpd/po/zh_Hans/rtp2httpd.po Add localized strings for NAT mode UI.
openwrt-support/luci-app-rtp2httpd/po/templates/rtp2httpd.pot Add template strings for NAT mode UI.
openwrt-support/luci-app-rtp2httpd/htdocs/luci-static/resources/view/rtp2httpd.js Add LuCI form option for selecting NAT mode.
ikuai-support/rtp2httpd/scripts/start.sh Add env-driven --rtsp-nat-mode CLI wiring.
ikuai-support/rtp2httpd/app/option.json Add iKuai UI/config option for NAT mode.
e2e/test_rtsp_zte_nat.py New end-to-end tests covering ZTE punch bytes, ordering, interface alignment, redirects, IPv6 fallback, and reload behavior.
e2e/helpers/mock_rtsp.py Add ZTE-capable mock RTSP server and request event instrumentation.
e2e/helpers/init.py Export the new MockRTSPServerZTE helper.
docs/reference/configuration.md Document --rtsp-nat-mode and add sample config entries (ZH).
docs/en/reference/configuration.md Document --rtsp-nat-mode and add sample config entries (EN).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rtp2httpd.conf Outdated
Comment thread docs/reference/configuration.md Outdated
Comment thread docs/en/reference/configuration.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5c1968f69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ikuai-support/rtp2httpd/scripts/start.sh
Comment thread ikuai-support/rtp2httpd/app/option.json Outdated
Comment thread e2e/helpers/mock_rtsp.py Outdated
Comment thread src/configuration.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants